package com.caoheng.oms.service.impl;

import com.caoheng.entity.MerchantInfo;
import com.caoheng.entity.MerchantInfoExample;
import com.caoheng.mapper.MerchantInfoMapper;
import com.caoheng.oms.service.IMerchantInfoService;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class MerchantInfoServiceImpl implements IMerchantInfoService {

    private MerchantInfoMapper merchantInfoMapper;

    public MerchantInfoServiceImpl(ObjectProvider<MerchantInfoMapper> objectProvider){
        this.merchantInfoMapper = objectProvider.getIfAvailable();
    }

    @Override
    public int addMerchantInfo(MerchantInfo merchantInfo) {
        return merchantInfoMapper.insert(merchantInfo);
    }

    @Override
    public int updateMerchantInfo(MerchantInfo merchantInfo) {
        return merchantInfoMapper.updateByPrimaryKey(merchantInfo);
    }

    @Override
    public MerchantInfo getMerchantInfo(String id) {
        return null;
    }

    @Override
    public List<MerchantInfo> getMerchantInfoList() {
        MerchantInfoExample example = new MerchantInfoExample();
        example.setOrderByClause("create_time desc");
        return merchantInfoMapper.selectByExample(example);
    }
}
